package com.um.jdy.app.charge.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.um.jdy.app.charge.entity.dto.ComplaintDTO;
import com.um.jdy.app.charge.entity.vo.ComplaintOrderVO;
import com.um.jdy.app.charge.manager.ComplaintOrderManager;
import com.um.jdy.common.base.entity.vo.ProblemVO;
import com.um.springboot.starter.orm.entity.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotBlank;

@RestController
@RequestMapping("/api/v1/complaint/order")
@SaCheckLogin
@Validated
@AllArgsConstructor
@Api(tags = "投诉订单")
public class ComplaintOrderController {

    ComplaintOrderManager complaintOrderManager;

    @ApiOperation("提交投诉订单")
    @PostMapping()
    public Response addComplaintOrder(@RequestBody ComplaintDTO dto) {
        return complaintOrderManager.addComplaintOrder(dto);
    }

    @ApiOperation("查询故障问题详情")
    @GetMapping("problem/{id}")
    public Response<ProblemVO> getProblemInfo(@ApiParam("问题id") @PathVariable @NotBlank String id) {
        return Response.success(complaintOrderManager.getProblemInfo(id));
    }

    @ApiOperation("查询订单及问题列表")
    @GetMapping("{id}")
    public Response<ComplaintOrderVO> getComplaintOrder(@ApiParam("订单id") @PathVariable @NotBlank String id) {
        return Response.success(complaintOrderManager.getComplaintOrder(id));
    }

}
